#include "Scene.h"


Scene::Scene(float posX, float posY, float width, float height, Resources* res, int kind, int number, int depth)
:GameObject(posX, posY, width, height, res, number, depth)
{
	if (kind != ID::ID_Mountain  && kind != ID::ID_House)
		_sprite = new Sprite(_resources->Cloud, 4, 2, 0.4f);
	else
		_sprite = new Sprite(_resources->Mountain, 4, 2, 0.2f);

	switch (kind)
	{
	case ID::ID_Cloud:
		_id = ID::ID_Cloud;
		_sprite->Next(0);
		break;
	case ID::ID_Grass:
		_id = ID::ID_Grass;
		_sprite->Next(2);
		break;
	case ID::ID_Mountain:
		_id = ID_Mountain;
		break;
	case ID::ID_House:
		_id = ID::ID_House;
	default:
		break;
	}

	_isStatic = true;
}


Scene::~Scene()
{
}

void Scene::Update(float time, QNode* &Tree)
{
	if (_id == ID::ID_Mountain || _id == ID::ID_House) return;

	if (_id == ID_Cloud)
		_sprite->Next(0, 1, time);
	else
		_sprite->Next(2, 3, time);
}

void Scene::Render(LPD3DXSPRITE spriteHandler, Viewport* viewport)
{
	RECT rect;

	switch (_id)
	{
	case ID::ID_Cloud:
	case ID::ID_Grass:
		_sprite->Render(spriteHandler, _pos_x, _pos_y, false, viewport);
		break;
	case ID::ID_Mountain:
		rect.left = 0;
		rect.right = 400;
		rect.top = 0;
		rect.bottom = 130;
		_sprite->Render(spriteHandler, _pos_x, _pos_y, rect, viewport);
		break;
	case ID::ID_House:
		rect.left = 400;
		rect.right = 775;
		rect.top = 0;
		rect.bottom = 295;
		_sprite->Render(spriteHandler, _pos_x, _pos_y, rect, viewport);
	default:
		break;
	}
	
}